package net.sahv.bdyz.util;
import java.awt.*; 

import java.io.*; 

import java.awt.image.*; 

import com.sun.image.codec.jpeg.*; 

import javax.imageio.*; 

public class testImg {

@SuppressWarnings("restriction")
public void ImgYin(String s,String ImgName){ 

try{ 

File _file = new File(ImgName); 

Image src = ImageIO.read(_file); 

int wideth=src.getWidth(null); 

int height=src.getHeight(null); 

BufferedImage image=new BufferedImage(wideth,height,BufferedImage.TYPE_INT_RGB); 

Graphics g=image.createGraphics(); 

g.drawImage(src,0,0,wideth,height,null); 

g.setColor(Color.white); 

g.setFont(new Font("宋体",Font.PLAIN,30)); 

Font aa=new Font("宋体",Font.PLAIN,30); 

//g.drawString(s,wideth-150,height-10); 
g.drawString(s,wideth/2-30,height/2); 
g.dispose(); 

FileOutputStream out=new FileOutputStream(ImgName); 

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); 

encoder.encode(image); 

out.close(); 

} 

catch(Exception e){ 

System.out.println(e); 

} 

} 

}
